
Technical Q&A's
PS 01 - Problem with Process Manager's WakeUpProcess Function (1-May-95)
Q I call the Process Manager's WakeUpProcess function from a completion routine
to tell my application that my asynchronous request has completed. However,
sometimes it seems that WakeUpProcess is ignored and my application doesn't
wake up until the sleep value passed to WaitNextEvent expires. Does
WakeUpProcess really work?
A You're running into a bug in the Process Manager that is fixed in System 7.1.2
(and later). Before System 7.1.2, WakeUpProcess doesn't do anything if the
process being targeted is the active process and is executing the code in its
event loop when WakeUpProcess is called. There are three things you can do to
work around this problem.
First, in your completion routine, change the value of the sleep variable your
application passes to WaitNextEvent to 0. That way, your next call to
WaitNextEvent will give up as little time as possible.
Second, check the sleep variable just before you call WaitNextEvent and verify
that it is zero (meaning your completion routine has been called). That should
prevent WaitNextEvent from even being called when you don't need it to be
called.
Third, for the sleep value you pass to WaitNextEvent while waiting for the call
to complete, use a value that's small enough so that even if you hit the very
small race window left by the first two suggestions above, your overall
performance won't be affected very much.
Technical Support
Technical Q&As
Contents | Next Question

Main |
Page One |
What's New |
Apple Computer, Inc. |
Find It |
Contact Us |
Help